package com.ize.controller.student;


import com.ize.entity.dto.ConsultationAddDto;
import com.ize.entity.pojo.Doctor;
import com.ize.entity.pojo.UserCom;
import com.ize.entity.vo.DoctorConsulationVo;
import com.ize.mapper.ConsultationMapper;
import com.ize.result.Result;
import com.ize.service.ConsultationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;
import java.util.List;

@RestController("student")
@RequestMapping("/student/doctor")
@Slf4j
@Api(tags = "用户问诊")
@RequiredArgsConstructor
public class ConsultationController {

    private final ConsultationService consultationService;
    private final ConsultationMapper consultationMapper;

    @PostMapping
    @ApiOperation("留言")
    public Result add(@RequestBody ConsultationAddDto consultationAddDto){
        log.info("留言信息{}",consultationAddDto);
        consultationService.add(consultationAddDto);
        return Result.success();
    }

    @GetMapping("/getInfo")
    @ApiOperation("获取医生信息")
    public Result<List<Doctor>> getInfo(@RequestParam(required = false) String key,
                                        @RequestParam(required = false) String kezhen){
        log.info("在线询问: key :{}",key);
        List<Doctor> d = consultationService.getDoctor(key,kezhen);
        return Result.success(d);
    }

    @GetMapping("/getDtail")
    @ApiOperation("获取医生详细信息")
    public Result<Doctor> getDtail(@RequestParam Long id){
        log.info("医生: id:{}",id);
        Doctor doctor = consultationService.getDoctorDetail(id);
        return Result.success(doctor);
    }

    @GetMapping("/getDoctorConsulation")
    @ApiOperation("获取医生恢复")
    public Result<List<DoctorConsulationVo>> getDoctorConsulation(){
        log.info("正在获取医生回复.....");
        List<DoctorConsulationVo> b = consultationService.getConsulationByUserId();
        return Result.success(b);
    }
}
